/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import DTO.*;
import java.util.Date;
import java.util.List;
import org.hibernate.Query;

/**
 *
 * @author acazares
 */
public class ConcursoDAO extends UtilDao{
    
    protected String objName = "Concurso";
    protected String objAlias = "concurso";
    
    
    public Concurso getConcursoById(String id){
        Concurso concurso = new Concurso();        
        try {
            tx = sesion.beginTransaction();
            Query q = sesion.createQuery ("FROM Concurso AS concurso WHERE id='"+id+"'");
            List<Concurso> usersList = (List<Concurso>) q.list();
            concurso = usersList.size()>0?usersList.get(0):concurso;
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            return concurso;
        }
    }
    
    
    /*
    public void update(Concurso concurso){
        try {
            tx = sesion.beginTransaction();
            sesion.update(concurso);
            tx.commit();
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
    /*
    public int count(){
        try {
            tx = sesion.beginTransaction();
            return sesion.createQuery("from Concurso").list().size();
        }catch (Exception e) {            
            e.printStackTrace();
            return 0;
        }
    }*/    
    
    
}
